<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function Person(name, age) {
      this.name = name
      this.age = age

    }

    // Person.prototype.sayHi = function () {
    //   console.log(this.name + '吃饭')
    // }

    function Nanren() {

    }

    Nanren.prototype = new Person('男人', 18)
    Nanren.prototype.constructor = Nanren
    const nanren = new Nanren()
    console.log(nanren)

    function Nvren() {

    }
    Nvren.prototype = new Person('女人', 20)
    Nvren.prototype.constructor = Nvren
    Nvren.prototype.sayHi = function () {
      console.log('生孩子')
    }
    const nvren = new Nvren()
    console.log(nvren)
    nvren.sayHi()

  </script>
</body>

</html>